﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Noodles.Core.Repositories;
using Noodles.Core.Model;
using Noodles.Core.Enums;
using NoodlesCms.Configuration.Extensions;
using NoodlesCms.Areas;
using NoodlesCms.Configuration;

namespace NoodlesCms.Configuration
{
    public class SEOToIdAttribute : ActionFilterAttribute
    {
        /**Reffered  http://haacked.com/archive/2010/02/21/manipulating-action-method-parameters.aspx  **/
                

        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            string slugTitle = filterContext.RouteData.Values["SeoTitle"] as string;
            string normalTitle = slugTitle.Replace('-', ' ');

            if (slugTitle != null)
            {
                int id=0;
               // Slugs.TryGetValue(slug, out id);
               // id=blogrepository.GetIDFromTitle(normalTitle);
                filterContext.ActionParameters["id"] = 0;
                filterContext.ActionParameters["Title"] = normalTitle;
            }
            base.OnActionExecuting(filterContext);
        }
    }

}